package make.free.app.mcaro.game;

import make.free.app.mcaro.activity.Game;


import org.anddev.andengine.engine.Engine;
import org.anddev.andengine.entity.scene.Scene;
import org.anddev.andengine.entity.text.ChangeableText;
import org.anddev.andengine.opengl.font.Font;
import org.anddev.andengine.opengl.texture.TextureOptions;
import org.anddev.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;


//nam test
public class Change {
	private Engine mEngine;
	private Scene mScene;
	private int position;

	private ChangeableText mLuot, mPlayer;
	private BitmapTextureAtlas mFontBitmapAtlast;
	private Font mFont;
	private String luot = "Lượt:";

	public Change(Context mContext, Engine mEngine, Scene mScene, int position) {
		super();
		this.mEngine = mEngine;
		this.mScene = mScene;
		this.position = position;
	}

	public void onLoadResource() {
		mFontBitmapAtlast = new BitmapTextureAtlas(256, 256,
				TextureOptions.BILINEAR_PREMULTIPLYALPHA);
		mFont = new Font(mFontBitmapAtlast, Typeface.create(Typeface.DEFAULT,
				Typeface.NORMAL), 30, true, Color.BLACK);
		mEngine.getTextureManager().loadTexture(mFontBitmapAtlast);
		mEngine.getFontManager().loadFont(mFont);
	}

	public void onLoadScence() {
		mLuot = new ChangeableText(position, 4, mFont, luot);
		mPlayer = new ChangeableText((int) (position + mLuot.getWidth() + 4),
				4, mFont, "Đang chờ");

		mScene.attachChild(mLuot);
		mScene.attachChild(mPlayer);

	}

	public void updatePlay(int luot) {
		if (Game.isGameAI) {
			if (luot == 1) {
				mPlayer.setText("Bạn");
			} else {
				mPlayer.setText("Máy");
			}
		}
		else
		{
			if (luot == 1) {
				mPlayer.setText("Bạn");
			} else {
				mPlayer.setText("Đ.Thủ");
			}
		}
	}

}
